package edu.nyp.locationservicesapp.activity;

import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import java.util.Locale;
import edu.nyp.locationservicesapp.R;
import edu.nyp.locationservicesapp.base.BaseActivity;

/**
 * 服务协议界面
 */
public class AgreementActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_agreement);
        initView();
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }
    
    protected void initView() {
        WebView webAgree = (WebView)findViewById(R.id.webview_agreement);
        webAgree.setWebChromeClient(new WebChromeClient());
        webAgree.setWebViewClient(new WebViewClient());
        webAgree.getSettings().setDefaultTextEncodingName("utf-8");
        WebSettings wSet = webAgree.getSettings();
        wSet.setJavaScriptEnabled(true);
        Locale locale = getResources().getConfiguration().locale;
        String language = locale.getLanguage();
        if (language.equals("en")){
            webAgree.loadUrl("file:///android_asset/agree.html");
        }else {
            webAgree.loadUrl("file:///android_asset/agreement.html");
        }
    }
}
